"use strict";var TABS={},GUI_control=function(){this.auto_connect=!1,this.connecting_to=!1,this.connected_to=!1,this.connect_lock=!1,this.firmware_is_flashing=!1,this.active_tab,this.tab_switch_in_progress=!1,this.operating_system,this.optional_usb_permissions=!1,this.interval_array=[],this.timeout_array=[],this.defaultAllowedTabsWhenDisconnected=["landing","setup","debug","autocontrol","database"],this.defaultAllowedTabsWhenConnected=["landing","setup","firmware_flasher","debug","cutoffs","motors","utilities","autocontrol","database"],this.allowedTabs=this.defaultAllowedTabsWhenDisconnected,navigator.appVersion.indexOf("Win")!=-1?this.operating_system="Windows":navigator.appVersion.indexOf("Mac")!=-1?this.operating_system="MacOS":navigator.appVersion.indexOf("CrOS")!=-1?this.operating_system="ChromeOS":navigator.appVersion.indexOf("Linux")!=-1?this.operating_system="Linux":navigator.appVersion.indexOf("X11")!=-1?this.operating_system="UNIX":this.operating_system="Unknown",googleAnalytics.sendEvent("OS","Using",this.operating_system)};GUI_control.prototype.interval_add=function(t,e,r,a){var i={name:t,timer:null,code:e,interval:r,fired:0,paused:!1};return 1==a&&(e(),i.fired++),i.timer=setInterval(function(){e(),i.fired++},r),this.interval_array.push(i),i},GUI_control.prototype.interval_remove=function(t){for(var e=0;e<this.interval_array.length;e++)if(this.interval_array[e].name==t)return clearInterval(this.interval_array[e].timer),this.interval_array.splice(e,1),!0;return!1},GUI_control.prototype.interval_pause=function(t){for(var e=0;e<this.interval_array.length;e++)if(this.interval_array[e].name==t)return clearInterval(this.interval_array[e].timer),this.interval_array[e].paused=!0,!0;return!1},GUI_control.prototype.interval_resume=function(t){for(var e=0;e<this.interval_array.length;e++)if(this.interval_array[e].name==t&&this.interval_array[e].paused){var r=this.interval_array[e];return r.timer=setInterval(function(){r.code(),r.fired++},r.interval),r.paused=!1,!0}return!1},GUI_control.prototype.interval_kill_all=function(t){for(var e=this,r=0,a=this.interval_array.length-1;a>=0;a--){var i=!1;t&&t.forEach(function(t){e.interval_array[a].name==t&&(i=!0)}),i||(clearInterval(this.interval_array[a].timer),this.interval_array.splice(a,1),r++)}return r},GUI_control.prototype.timeout_add=function(t,e,r){var a=this,i={name:t,timer:null,timeout:r};return i.timer=setTimeout(function(){e();var t=a.timeout_array.indexOf(i);t>-1&&a.timeout_array.splice(t,1)},r),this.timeout_array.push(i),i},GUI_control.prototype.timeout_remove=function(t){for(var e=0;e<this.timeout_array.length;e++)if(this.timeout_array[e].name==t)return clearTimeout(this.timeout_array[e].timer),this.timeout_array.splice(e,1),!0;return!1},GUI_control.prototype.timeout_kill_all=function(){for(var t=0,e=0;e<this.timeout_array.length;e++)clearTimeout(this.timeout_array[e].timer),t++;return this.timeout_array=[],t},GUI_control.prototype.log=function(t){var e=$("div#log"),r=new Date,a=r.getFullYear(),i=r.getMonth()<9?"0"+(r.getMonth()+1):r.getMonth()+1,n=r.getDate()<10?"0"+r.getDate():r.getDate(),o=(r.getHours()<10?"0"+r.getHours():r.getHours())+":"+(r.getMinutes()<10?"0"+r.getMinutes():r.getMinutes())+":"+(r.getSeconds()<10?"0"+r.getSeconds():r.getSeconds()),s="{0}-{1}-{2} {3}".format(a,i,n," @ "+o);GUI_log+="<p>"+s+" -- "+t+"</p>",$("div.wrapper",e).append("<p>"+s+" -- "+t+"</p>"),e.scrollTop($("div.wrapper",e).height())},GUI_control.prototype.refresh_log=function(){var t=$("div#log");$("div.wrapper",t).html(GUI_log),t.scrollTop($("div.wrapper",t).height())},GUI_control.prototype.tab_switch_cleanup=function(t){this.active_tab?TABS[this.active_tab].cleanup(t):t()};var GUI=new GUI_control;